import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { estimateRoleUnit } from "@/lib/estimate"; import { marketIndex, nearbyListings } from "@/lib/queries"; import { dbAvailable } from "@/lib/db"; import { fmtPrice, fmtPct, fmtInt, fmtDate } from "@/lib/format"; import { Notice, Stat } from "@/components/ui"; import { EstimateBreakdown } from "@/components/estimate-breakdown"; import { IndexChart } from "@/components/price-chart"; import { MapView } from "@/components/map-view"; import { ListingCardView } from "@/components/listing-card"; import { MortgageWidget } from "@/components/mortgage-widget"; export const dynamic = "force-dynamic"; type Props = { params: Promise<{ id: string }> }; export async function generateMetadata({ params }: Props): Promise { const { id } = await params; const e = dbAvailable() ? estimateRoleUnit(decodeURIComponent(id)) : null; return { title: e ? `Estimation — ${e.subject.label}, ${e.subject.city}` : "Estimation", robots: { index: false } }; } export default async function EstimationPage({ params }: Props) { const { id } = await params; if (!dbAvailable()) notFound(); const e = estimateRoleUnit(decodeURIComponent(id)); if (!e) notFound(); const r = e.result; const u = e.roleUnit!; const idx = marketIndex(e.indexType); const near = nearbyListings(e.subject.lat, e.subject.lng, "sale", null, 4); return (

Valeur estimée · {fmtDate(new Date().toISOString())}

{fmtPrice(r.estimate)}

{fmtPrice(r.low)} – {fmtPrice(r.high)} · confiance {r.confidenceLevel} ({r.confidencePct} %)

{e.subject.label}

{u.city} · {u.cubf_label ?? u.type_prop}{u.year_built ? ` · construite en ${u.year_built}` : ""}{u.floor_area_m2 ? ` · ${fmtInt(u.floor_area_m2)} m² habitables` : ""}{u.land_area_m2 ? ` · terrain ${fmtInt(u.land_area_m2)} m²` : ""}{u.n_units && u.n_units > 1 ? ` · ${u.n_units} logements` : ""}

Comparables ajustés ({r.nCompsUsed})

{r.comps.map((c) => )}
VenteDatePrixAjustementsAjustéDist.
{c.street ?? "Adresse non publiée"}{c.city} · {c.propertyType ?? "n/d"}{c.floorArea ? ` · ${Math.round(c.floorArea)} m²` : ""}{c.yearBuilt ? ` · ${c.yearBuilt}` : ""}{fmtDate(c.date)}{fmtPrice(c.amount)}marché {c.adjTime >= 0 ? "+" : ""}{fmtPrice(c.adjTime)}
superficie {c.adjArea >= 0 ? "+" : ""}{fmtPrice(c.adjArea)}
âge {c.adjAge >= 0 ? "+" : ""}{fmtPrice(c.adjAge)}
{fmtPrice(c.adjustedPrice)}{c.distanceM < 1000 ? `${Math.round(c.distanceM)} m` : `${(c.distanceM / 1000).toFixed(1)} km`}
{idx.length > 1 &&

Évolution du marché ({e.indexType})

Indice mensuel du prix au m² par type de propriété, base 100 = dernier mois ({idx[idx.length - 1].month}). Source : base de transactions Toveli.

}

Méthode, données et limites

{e.method.name} · {e.method.version}

Entrées : {e.method.inputs.join(" ; ")}.

    {e.method.limits.map((x) =>
  • {x}
  • )}
{e.method.disclaimer}

Financer cette valeur

); }